<template>
  <div class='box'>
    <div class="con">
      <div class="inputLi flex vc hs">
        <div class='lable'>捐赠姓名</div>
        <input v-model="info.name" type="text" placeholder="请填写真实姓名" value=""/>
      </div>
      <div class="inputLi flex vc hs">
        <div class='lable'>捐赠金额</div>
        <input v-model="info.donate" type="text" placeholder="请填写捐赠金额" value=""/>
      </div>
      <div class="inputLi flex vc hs">
        <div class='lable'>联系方式</div>
        <input v-model="info.contact" type="text" placeholder="请输入联系方式" value=""/>
      </div>
      <div class="inputLi flex vc hb">
        <div class='lable long'>校友</div>
        <van-switch v-model="info.alumna" size="24px" active-color="#C4AC7D" inactive-color="#CBC8CB"/>
      </div>
      <div class="inputLi flex vc hb">
        <div class='lable long'>是否公开捐赠信息</div>
        <van-switch v-model="info.anonymous" size="24px" active-color="#C4AC7D" inactive-color="#CBC8CB"/>
      </div>
      <div class="inputLi flex vc hb">
        <div class='lable long'>是否开具发票</div>
        <van-switch v-model="info.invoice" size="24px" active-color="#C4AC7D" inactive-color="#CBC8CB"/>
      </div>
    </div>
    <button class='submit' @click='submit'>立即支付</button>
    <van-popup v-model="popup" position="bottom">
      <van-picker show-toolbar :columns="slots" @cancel="popup = !popup" @confirm="onConfirm"/>
    </van-popup>
    <van-popup v-model="show">
      <div class="tan">
        <img class='bg' src="../../assets/img/login/payBg.png" alt="">
        <img class='close' @click='show=!show' src="../../assets/img/login/close.png" alt="">
        <div class='tit'>
          <p>感谢您的捐赠</p>
          <p>特此颁证</p>
        </div>
        <div class="zs flex column ha">
          <p>证书编号</p>
          <p>{{this.info.certificate}}</p>
        </div>
        <div class="cha">
          <router-link to="/donCer">查看证书</router-link>
        </div>
      </div>
    </van-popup>
  </div>
</template>

<script>
import { Popup, Picker, Switch, Toast } from 'vant'
import { donatePay } from '@/api/project'

export default {
  components: {
    [Popup.name]: Popup,
    [Picker.name]: Picker,
    [Switch.name]: Switch,
    [Toast.name]: Toast
  },
  data () {
    return {
      checked: true,
      info: {
        type: '',
        name: '',
        radio: ''
      },
      popup: false,
      show: false,
      slots: ['普票', '增值税发票']
    }
  },

  created () {

  },

  methods: {
    onConfirm (picker, values) {
      this.info.type = picker
      this.popup = false
    },
    submit () {
      this.info.projectId = this.$route.query.projectId
      donatePay(this.info).then(response => {
        this.show = true
        this.info.certificate = response.data.certificate
      })
    }
  }
}
</script>

<style scoped>
  .flex {
    width: auto;
  }

  .box {
    width: 100vw;
    height: 100vh;
    background: #fff;
  }

  .con {
    padding: 0 15px;
  }

  .inputLi {
    padding: 18px 5px;
    border-bottom: 1px solid #EEEEEE;
    font-size: 15px;
    color: #535353;
  }

  .lable {
    width: 150px;
    font-size: 16px;
    color: #000;
  }

  .long {
    width: 160px;
  }

  input {
    width: calc(100% - 90px);
    border: 0;
    outline: none;
  }

  .radio {
    font-size: 14px;
  }

  .pic {
    width: calc(100% - 168px);
    text-align: right;
    padding-right: 15px;
  }

  .back {
    width: 8px;
    height: 16px;
  }

  .line {
    width: 100%;
    height: 2px;
    background: #E1E0DF;
  }

  .submit {
    display: block;
    width: 328px;
    height: 50px;
    background: #903B3F;
    color: #fff;
    margin: 130px auto 0;
    text-align: center;
    line-height: 50px;
    font-size: 18px;
  }

  .van-popup {
    background: rgba(0, 0, 0, 0);
  }

  .tan {
    width: 100vw;
    height: 100vh;
    padding: 40px 0 0;
    position: relative;
  }

  .tan .bg {
    display: block;
    margin: 0 auto;
    width: 308px;
  }

  .close {
    width: 27px;
    height: 27px;
    position: absolute;
    top: 40px;
    right: 40px;
  }

  .tan .tit {
    font-size: 20px;
    color: #434343;
    position: absolute;
    top: 140px;
    left: 0;
    width: 100%;
    text-align: center;
  }

  .tan .zs {
    position: absolute;
    top: 230px;
    left: 50%;
    width: 215px;
    height: 67px;
    margin-left: -107px;
    background: rgba(228, 215, 194, 0.5);
    border: 0.5px dashed #666;
    font-size: 15px;
    color: #222;
    text-align: center;
    padding: 5px 0;
  }

  .tan .cha {
    position: absolute;
    top: 350px;
    left: 50%;
    width: 157px;
    height: 41px;
    margin-left: -78px;
    background: #77292D;
    border-radius: 5px;
    font-size: 16px;
    color: #fff;
    text-align: center;
    line-height: 41px;
  }

  .tan .cha a {
    font-size: 16px;
    color: #fff;
  }
</style>
